Timespan conversion - Mailing list pgsql-sql

From Herouth Maoz
Subject Timespan conversion
Date
Msg-id l03110703b233e2cdd004@[147.233.159.109]
Whole thread Raw
List pgsql-sql
I currently run Postgres 6.2.1.

I wanted to use it to compute my basketball statistics (the classical
relational database application) - enter the rows from the box scores, and
get all sorts of statistics.

My question relates to the 'minutes played' column. The natural
implementation is timespan, because I get times in mm:ss format. Timespans
sum up nicely. The problem begins in calculations such as "average minutes
per game", "minutes between rebounds", etc.

There is no problem in converting timespans to float. I just take the
date_part( 'epoch', timespan_field ), and divide it by, say, 60. My problem
is, after I divide this by the number of games, how do I convert back to
timespan?

Also, is there a way to receive '20:30' or maybe '00:20:30' and not '20
minutes 30 seconds' as a display from timespan? I don't want to build an
application for all this, because, frankly, it's just a hobby. Most of the
work can be done rather well in simplest SQL.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma



pgsql-sql by date:

Previous
From: "Gemeinschaft Studienarbeit Datenbanken"
Date:
Subject: Problems with inserting into tables...
Next
From: "Gemeinschaft Studienarbeit Datenbanken"
Date:
Subject: Another nut to crack with insertion into tables... *sigh*